install ggmap from github, there are recent changes in google maps API policy. You need to get a key from google maps, to make a call to google maps API to retrieve static map or geo coding. Newest version of ggmap packgae that is comapatible with recent changes in API is available thru github not CRAN.
#if(!requireNamespace("devtools")) install.packages("devtools")
#devtools::install_github("dkahle/ggmap")
library(devtools)
library(ggmap)
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
citation("ggmap")
##
## To cite ggmap in publications, please use:
##
## D. Kahle and H. Wickham. ggmap: Spatial Visualization with
## ggplot2. The R Journal, 5(1), 144-161. URL
## http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf
##
## A BibTeX entry for LaTeX users is
##
## @Article{,
## author = {David Kahle and Hadley Wickham},
## title = {ggmap: Spatial Visualization with ggplot2},
## journal = {The R Journal},
## year = {2013},
## volume = {5},
## number = {1},
## pages = {144--161},
## url = {https://journal.r-project.org/archive/2013-1/kahle-wickham.pdf},
## }
register_google("AIzaSyATaYHjTE0llqEnf9D2IwZz1vluNAcSWKw")
#install.packages(c("maps", "mapdata", "geosphere"))
library(maps)
library(mapdata)
library(geosphere)
library(tidyverse)
## ── Attaching packages ───────────────────────────────────── tidyverse 1.2.1 ──
## ✔ tibble 2.0.1 ✔ purrr 0.2.5
## ✔ tidyr 0.8.2 ✔ dplyr 0.7.8
## ✔ readr 1.3.1 ✔ stringr 1.3.1
## ✔ tibble 2.0.1 ✔ forcats 0.3.0
## ── Conflicts ──────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::map() masks maps::map()
Herearesomeapproximaterulesofthumbs:
• 1x10-5 degrees = 1m = 3 ft.
• 1x10-6 degrees = 0.1m = 10cm = 4 in.
• Formoreaccuratecalculation,youcanuse geospherepackage.
#install.packages("geosphere")
library(geosphere)
distVincentyEllipsoid(c(-80,40),c(-80,40.000001))
## [1] 0.1110346
distVincentyEllipsoid(c(-80,40),c(-80,40.00001))
## [1] 1.110346
to retrieve areas
usa <- map_data("usa")
state <- map_data("state")
county <- map_data("county")
world <- map_data("world")
world2 <- map_data("world2")
as.tibble(usa)
## Warning: `as.tibble()` is deprecated, use `as_tibble()` (but mind the new semantics).
## This warning is displayed once per session.
## # A tibble: 7,243 x 6
## long lat group order region subregion
## <dbl> <dbl> <dbl> <int> <chr> <chr>
## 1 -101. 29.7 1 1 main <NA>
## 2 -101. 29.7 1 2 main <NA>
## 3 -101. 29.7 1 3 main <NA>
## 4 -101. 29.6 1 4 main <NA>
## 5 -101. 29.6 1 5 main <NA>
## 6 -101. 29.6 1 6 main <NA>
## 7 -101. 29.6 1 7 main <NA>
## 8 -101. 29.6 1 8 main <NA>
## 9 -101. 29.6 1 9 main <NA>
## 10 -101. 29.6 1 10 main <NA>
## # … with 7,233 more rows
as.tibble(state)
## # A tibble: 15,537 x 6
## long lat group order region subregion
## <dbl> <dbl> <dbl> <int> <chr> <chr>
## 1 -87.5 30.4 1 1 alabama <NA>
## 2 -87.5 30.4 1 2 alabama <NA>
## 3 -87.5 30.4 1 3 alabama <NA>
## 4 -87.5 30.3 1 4 alabama <NA>
## 5 -87.6 30.3 1 5 alabama <NA>
## 6 -87.6 30.3 1 6 alabama <NA>
## 7 -87.6 30.3 1 7 alabama <NA>
## 8 -87.6 30.3 1 8 alabama <NA>
## 9 -87.7 30.3 1 9 alabama <NA>
## 10 -87.8 30.3 1 10 alabama <NA>
## # … with 15,527 more rows
as.tibble(county)
## # A tibble: 87,949 x 6
## long lat group order region subregion
## <dbl> <dbl> <dbl> <int> <chr> <chr>
## 1 -86.5 32.3 1 1 alabama autauga
## 2 -86.5 32.4 1 2 alabama autauga
## 3 -86.5 32.4 1 3 alabama autauga
## 4 -86.6 32.4 1 4 alabama autauga
## 5 -86.6 32.4 1 5 alabama autauga
## 6 -86.6 32.4 1 6 alabama autauga
## 7 -86.6 32.4 1 7 alabama autauga
## 8 -86.6 32.4 1 8 alabama autauga
## 9 -86.6 32.4 1 9 alabama autauga
## 10 -86.6 32.4 1 10 alabama autauga
## # … with 87,939 more rows
as.tibble(world)
## # A tibble: 99,338 x 6
## long lat group order region subregion
## <dbl> <dbl> <dbl> <int> <chr> <chr>
## 1 -69.9 12.5 1 1 Aruba <NA>
## 2 -69.9 12.4 1 2 Aruba <NA>
## 3 -69.9 12.4 1 3 Aruba <NA>
## 4 -70.0 12.5 1 4 Aruba <NA>
## 5 -70.1 12.5 1 5 Aruba <NA>
## 6 -70.1 12.6 1 6 Aruba <NA>
## 7 -70.0 12.6 1 7 Aruba <NA>
## 8 -70.0 12.6 1 8 Aruba <NA>
## 9 -69.9 12.5 1 9 Aruba <NA>
## 10 -69.9 12.5 1 10 Aruba <NA>
## # … with 99,328 more rows
as.tibble(world2)
## # A tibble: 99,385 x 6
## long lat group order region subregion
## <dbl> <dbl> <dbl> <int> <chr> <chr>
## 1 290. 12.5 1 1 Aruba <NA>
## 2 290. 12.4 1 2 Aruba <NA>
## 3 290. 12.4 1 3 Aruba <NA>
## 4 290. 12.5 1 4 Aruba <NA>
## 5 290. 12.5 1 5 Aruba <NA>
## 6 290. 12.6 1 6 Aruba <NA>
## 7 290. 12.6 1 7 Aruba <NA>
## 8 290. 12.6 1 8 Aruba <NA>
## 9 290. 12.5 1 9 Aruba <NA>
## 10 290. 12.5 1 10 Aruba <NA>
## # … with 99,375 more rows
#each observation is a point on map. Each group is a shape. World has country as region.
ggplot has data, geom_path maps x and y axis , group is important to connect dots of same group coord_map - specify projection - default Marcator, Lambert, Azimu, Gnomonic, Alberts, equidistant
ggplot(state) +
geom_path(aes(long, lat, group=group)) +
coord_map("mercator")
#use any one at a time
coord_map("lambert", lat0=30, lat1=45)
## <ggproto object: Class CoordMap, Coord, gg>
## aspect: function
## backtransform_range: function
## clip: on
## default: FALSE
## distance: function
## is_free: function
## is_linear: function
## labels: function
## limits: list
## modify_scales: function
## orientation: NULL
## params: list
## projection: lambert
## range: function
## render_axis_h: function
## render_axis_v: function
## render_bg: function
## render_fg: function
## setup_data: function
## setup_layout: function
## setup_panel_params: function
## setup_params: function
## transform: function
## super: <ggproto object: Class CoordMap, Coord, gg>
coord_map("albers", lat0=30, lat1=45)
## <ggproto object: Class CoordMap, Coord, gg>
## aspect: function
## backtransform_range: function
## clip: on
## default: FALSE
## distance: function
## is_free: function
## is_linear: function
## labels: function
## limits: list
## modify_scales: function
## orientation: NULL
## params: list
## projection: albers
## range: function
## render_axis_h: function
## render_axis_v: function
## render_bg: function
## render_fg: function
## setup_data: function
## setup_layout: function
## setup_panel_params: function
## setup_params: function
## transform: function
## super: <ggproto object: Class CoordMap, Coord, gg>
coord_map("azequalarea")
## <ggproto object: Class CoordMap, Coord, gg>
## aspect: function
## backtransform_range: function
## clip: on
## default: FALSE
## distance: function
## is_free: function
## is_linear: function
## labels: function
## limits: list
## modify_scales: function
## orientation: NULL
## params: list
## projection: azequalarea
## range: function
## render_axis_h: function
## render_axis_v: function
## render_bg: function
## render_fg: function
## setup_data: function
## setup_layout: function
## setup_panel_params: function
## setup_params: function
## transform: function
## super: <ggproto object: Class CoordMap, Coord, gg>
coord_map("simpleconic", lat0=30, lat1=45)
## <ggproto object: Class CoordMap, Coord, gg>
## aspect: function
## backtransform_range: function
## clip: on
## default: FALSE
## distance: function
## is_free: function
## is_linear: function
## labels: function
## limits: list
## modify_scales: function
## orientation: NULL
## params: list
## projection: simpleconic
## range: function
## render_axis_h: function
## render_axis_v: function
## render_bg: function
## render_fg: function
## setup_data: function
## setup_layout: function
## setup_panel_params: function
## setup_params: function
## transform: function
## super: <ggproto object: Class CoordMap, Coord, gg>
coord_map("gnomonic", orientation=c(40,-100,0))
## <ggproto object: Class CoordMap, Coord, gg>
## aspect: function
## backtransform_range: function
## clip: on
## default: FALSE
## distance: function
## is_free: function
## is_linear: function
## labels: function
## limits: list
## modify_scales: function
## orientation: 40 -100 0
## params: list
## projection: gnomonic
## range: function
## render_axis_h: function
## render_axis_v: function
## render_bg: function
## render_fg: function
## setup_data: function
## setup_layout: function
## setup_panel_params: function
## setup_params: function
## transform: function
## super: <ggproto object: Class CoordMap, Coord, gg>
Beers
Columns
Row number
abv -The alcoholic content by volume with 0 being no alcohol and 1 being pure alcohol
ibu - International bittering units, which describe how bitter a drink is.
id -Unique ID
name -Name of the beer.
style -Beer style (lager, ale, IPA, etc.)
brewery_id - Unique identifier for brewery that produces this beer; can use to join with brewery info.
ounces -Size of beer in ounces.
brews brewery_id
name - Name of the brewery
city- City that the brewery is located in.
state- State that the brewery is located in.
beers <- read_csv("beers.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_double(),
## abv = col_double(),
## ibu = col_double(),
## id = col_double(),
## name = col_character(),
## style = col_character(),
## brewery_id = col_double(),
## ounces = col_double()
## )
brews1 <- read_csv("breweries.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_double(),
## name = col_character(),
## city = col_character(),
## state = col_character()
## )
stll <- read_csv("statelatlong.csv")
## Parsed with column specification:
## cols(
## State = col_character(),
## Latitude = col_double(),
## Longitude = col_double(),
## City = col_character()
## )
brews <- brews1 %>% rename(brewery_id=X1)
brewcnt <- brews %>% count(state) %>% rename(State=state)
#lower case for city
stll <- stll %>% mutate(region=str_to_lower(City))
#n is count of brews
stlab <- stll %>% right_join(brewcnt %>% arrange(-n) %>% head(5))
## Joining, by = "State"
TT <- state %>% left_join(stll) %>% left_join(brewcnt)
## Joining, by = "region"
## Joining, by = "State"
TT %>% ggplot() + geom_polygon(aes(long, lat, group=group, fill=n)) +
geom_text(data=stlab, mapping=aes(Longitude, Latitude,
label=str_c(State,"(",n,")")), size=2) +
coord_map("albers", lat0=30, lat1=45) +
theme_void()
beers <- beers %>% rename(beer_id=X1)
#to get state with most unique beers by Brewer id
bbs <- beers %>% full_join(brews, by="brewery_id")
bbscnt <- bbs %>% group_by(state) %>% summarize(n=n(), abv=mean(abv, na.rm=T)) %>%
rename(State=state) %>% ungroup()
cntlab <- stll %>% right_join(bbscnt %>% arrange(-n) %>% head(10))
## Joining, by = "State"
#to get state with strongest beers on average
abvlab <- stll %>% right_join(bbscnt %>% arrange(-abv) %>% head(10))
## Joining, by = "State"
UB <- state %>% left_join(stll) %>% left_join(bbscnt)
## Joining, by = "region"
## Joining, by = "State"
UB %>% ggplot() + geom_polygon(aes(long, lat, group=group, fill=n)) +
geom_text(data=cntlab, mapping=aes(Longitude, Latitude, label=str_c(State,"
(",n,")")), size=2) +
coord_map("mercator") + theme_void()
state %>% left_join(stll) %>% left_join(bbscnt) %>% ggplot() +
geom_polygon(aes(long, lat, group=group, fill=abv)) +
scale_fill_gradientn(
colors=c("#2c7bb6","#abd9e9","#ffffbf","#fdae61","#d7191c")) +
geom_text(data=abvlab, mapping=aes(Longitude, Latitude, label=sprintf("%s
(%.2f%%)", State, abv*100)), size=2) +
coord_map() +
theme_void()
## Joining, by = "region"
## Joining, by = "State"
sprintf(“I woke up at %s:%s%s a.m.”, 8, 0, 5)
#> [1] “I woke up at 8:05 a.m.”
4.1 C-style formatting options
The string format %s is just one of a larger list of available formatting options. The following table shows the most common formatting specifications:
Notation Description
%s a string
%d an integer
%0xd an integer padded with x leading zeros
%f decimal notation with six decimals
%.xf floating point number with x digits after decimal point
%e compact scientific notation, e in the exponent
%E compact scientific notation, E in the exponent
%g compact decimal or scientific notation (with e)
============= 5 is the length
sprintf(“%*d“, 5, 10)
#> [1]” 10"
==============
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
emp <- read_csv("output.csv")
## Parsed with column specification:
## cols(
## Year = col_double(),
## Month = col_character(),
## State = col_character(),
## County = col_character(),
## Rate = col_double()
## )
as.tibble(emp)
## # A tibble: 885,548 x 5
## Year Month State County Rate
## <dbl> <chr> <chr> <chr> <dbl>
## 1 2015 February Mississippi Newton County 6.1
## 2 2015 February Mississippi Panola County 9.4
## 3 2015 February Mississippi Monroe County 7.9
## 4 2015 February Mississippi Hinds County 6.1
## 5 2015 February Mississippi Kemper County 10.6
## 6 2015 February Mississippi Calhoun County 6.9
## 7 2015 February Mississippi Clarke County 7.9
## 8 2015 February Mississippi Jefferson County 14.3
## 9 2015 February Mississippi Madison County 4.5
## 10 2015 February Mississippi Sharkey County 11.1
## # … with 885,538 more rows
emp1 <- emp %>%
mutate(Date = mdy(sprintf("%s 01, %d", Month, Year)))
head(emp1)
## # A tibble: 6 x 6
## Year Month State County Rate Date
## <dbl> <chr> <chr> <chr> <dbl> <date>
## 1 2015 February Mississippi Newton County 6.1 2015-02-01
## 2 2015 February Mississippi Panola County 9.4 2015-02-01
## 3 2015 February Mississippi Monroe County 7.9 2015-02-01
## 4 2015 February Mississippi Hinds County 6.1 2015-02-01
## 5 2015 February Mississippi Kemper County 10.6 2015-02-01
## 6 2015 February Mississippi Calhoun County 6.9 2015-02-01
emp2 <- emp1 %>% mutate(Month=month(Date))
emp2
## # A tibble: 885,548 x 6
## Year Month State County Rate Date
## <dbl> <dbl> <chr> <chr> <dbl> <date>
## 1 2015 2 Mississippi Newton County 6.1 2015-02-01
## 2 2015 2 Mississippi Panola County 9.4 2015-02-01
## 3 2015 2 Mississippi Monroe County 7.9 2015-02-01
## 4 2015 2 Mississippi Hinds County 6.1 2015-02-01
## 5 2015 2 Mississippi Kemper County 10.6 2015-02-01
## 6 2015 2 Mississippi Calhoun County 6.9 2015-02-01
## 7 2015 2 Mississippi Clarke County 7.9 2015-02-01
## 8 2015 2 Mississippi Jefferson County 14.3 2015-02-01
## 9 2015 2 Mississippi Madison County 4.5 2015-02-01
## 10 2015 2 Mississippi Sharkey County 11.1 2015-02-01
## # … with 885,538 more rows
emp3 <- emp2 %>% arrange(Year, Month) %>%
group_by(Year, SC=str_c(State, County, sep="|"))
emp3
## # A tibble: 885,548 x 7
## # Groups: Year, SC [76,496]
## Year Month State County Rate Date SC
## <dbl> <dbl> <chr> <chr> <dbl> <date> <chr>
## 1 1990 1 Mississi… Newton County 7.7 1990-01-01 Mississippi|Newton…
## 2 1990 1 Mississi… Panola County 10.7 1990-01-01 Mississippi|Panola…
## 3 1990 1 Mississi… Monroe County 6.7 1990-01-01 Mississippi|Monroe…
## 4 1990 1 Mississi… Hinds County 5.9 1990-01-01 Mississippi|Hinds …
## 5 1990 1 Mississi… Kemper County 14.7 1990-01-01 Mississippi|Kemper…
## 6 1990 1 Mississi… Calhoun Coun… 8.6 1990-01-01 Mississippi|Calhou…
## 7 1990 1 Mississi… Clarke County 5.7 1990-01-01 Mississippi|Clarke…
## 8 1990 1 Mississi… Jefferson Co… 24 1990-01-01 Mississippi|Jeffer…
## 9 1990 1 Mississi… Madison Coun… 5.5 1990-01-01 Mississippi|Madiso…
## 10 1990 1 Mississi… Sharkey Coun… 23.2 1990-01-01 Mississippi|Sharke…
## # … with 885,538 more rows
emp3 <- emp2 %>% arrange(Year, Month) %>%
group_by(Year, SC=str_c(State, County, sep="|")) %>%
summarize(unemp=mean(Rate)) %>% ungroup() %>% separate(SC, c("State", "County"), sep="\\|")
word(string, start = 1L, end = start, sep = fixed(" “))
start
integer vector giving position of first word to extract. Defaults to first word. If negative, counts backwards from last character.
end
integer vector giving position of last word to extract. Defaults to first word. If negative, counts backwards from last character.
sep
separator between words. Defaults to single space.
sentences <- c(“Jane saw a cat”, “Jane sat down”)
word(sentences, 1)
“Jane” “Jane”
word(sentences, 2)
“saw” “sat”
word(sentences, -1)
“cat” “down” word(sentences, 2, -1)
emp2016 <- emp %>%
mutate(region=str_to_lower(State), subregion=str_to_lower(word(County, 1, -2))) %>%
filter(Year==2016)
div_colors = c("#2c7bb6","#abd9e9","#ffffbf","#fdae61","#d7191c")
county %>% left_join(emp2016) %>% ggplot() +
geom_polygon(aes(long, lat, group=group, fill=Rate)) +
scale_fill_gradientn(colors=div_colors) +
coord_map() + theme_minimal()
## Joining, by = c("region", "subregion")
#10 times duplicated county
ctyr <- as.tibble(county) %>%
mutate(`2007`=1, `2008`=1, `2009`=1, `2010`=1, `2011`=1, `2012`=1, `2013`=1, `2014`=1, `2015`=1, `2016`=1)
head(ctyr)
## # A tibble: 6 x 16
## long lat group order region subregion `2007` `2008` `2009` `2010`
## <dbl> <dbl> <dbl> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 -86.5 32.3 1 1 alaba… autauga 1 1 1 1
## 2 -86.5 32.4 1 2 alaba… autauga 1 1 1 1
## 3 -86.5 32.4 1 3 alaba… autauga 1 1 1 1
## 4 -86.6 32.4 1 4 alaba… autauga 1 1 1 1
## 5 -86.6 32.4 1 5 alaba… autauga 1 1 1 1
## 6 -86.6 32.4 1 6 alaba… autauga 1 1 1 1
## # … with 6 more variables: `2011` <dbl>, `2012` <dbl>, `2013` <dbl>,
## # `2014` <dbl>, `2015` <dbl>, `2016` <dbl>
ctyr %>% gather(Year, Dummy, `2007`:`2016`) %>%
mutate(Year=parse_integer(Year)) %>% select(-Dummy)
## # A tibble: 879,490 x 7
## long lat group order region subregion Year
## <dbl> <dbl> <dbl> <int> <chr> <chr> <int>
## 1 -86.5 32.3 1 1 alabama autauga 2007
## 2 -86.5 32.4 1 2 alabama autauga 2007
## 3 -86.5 32.4 1 3 alabama autauga 2007
## 4 -86.6 32.4 1 4 alabama autauga 2007
## 5 -86.6 32.4 1 5 alabama autauga 2007
## 6 -86.6 32.4 1 6 alabama autauga 2007
## 7 -86.6 32.4 1 7 alabama autauga 2007
## 8 -86.6 32.4 1 8 alabama autauga 2007
## 9 -86.6 32.4 1 9 alabama autauga 2007
## 10 -86.6 32.4 1 10 alabama autauga 2007
## # … with 879,480 more rows
emp10 <- emp %>%
mutate(region = str_to_lower(State), subregion = str_to_lower(word(County, 1, -2))) %>%
filter(Year >= 2007 & Year <= 2016)
#Unemployment rate over time in Ohio
ctyr %>% left_join(emp10) %>% filter(region == "ohio") %>% ggplot() + geom_polygon(aes(long, lat, group=group, fill = Rate)) + scale_fill_gradientn(colors=div_colors) +
facet_wrap(~Year, ncol=5) +
coord_map() + theme_void()
## Joining, by = c("region", "subregion")
ctyr %>% left_join(emp10) %>% filter(region=="ohio") %>% ggplot() + geom_polygon(aes(long, lat, group=group, fill=Rate)) + scale_fill_gradientn(colors=div_colors) +
facet_wrap(~Year, ncol=5) +
coord_map() + theme_void()
## Joining, by = c("region", "subregion")
Regenerate the google key if session restarted.
The link to get response to geocoding query:
https://maps.googleapis.com/maps/api/geocode/json?address=The%20Ohio%20Stadium&key=YOUR_KEY
library(ggmap)
register_google(key = "AIzaSyATaYHjTE0llqEnf9D2IwZz1vluNAcSWKw")
#gc will be a pair of lat and lon for the name of the location given
gc <- geocode("The Ohio Stadium")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=The+Ohio+Stadium&key=xxx
gc
## # A tibble: 1 x 2
## lon lat
## <dbl> <dbl>
## 1 -83.0 40.0
#reverse geo code address
rgc_address <- revgeocode(c(-83.01973, 40.00166))
## Source : https://maps.googleapis.com/maps/api/geocode/json?latlng=40.00166,-83.01973&key=xxx
## Multiple addresses found, the first will be returned:
## 411 Woody Hayes Dr, Columbus, OH 43210, USA
## Unnamed Road, Columbus, OH 43210, USA
## Columbus, OH 43210, USA
## The Ohio State University, Columbus, OH, USA
## Columbus, OH, USA
## Franklin County, OH, USA
## Ohio, USA
## United States
rgc_address
## [1] "411 Woody Hayes Dr, Columbus, OH 43210, USA"
#Gives more details of the address
rgc_more <- revgeocode(c(-83.01973, 40.00166), output="address")
## Multiple addresses found, the first will be returned:
## 411 Woody Hayes Dr, Columbus, OH 43210, USA
## Unnamed Road, Columbus, OH 43210, USA
## Columbus, OH 43210, USA
## The Ohio State University, Columbus, OH, USA
## Columbus, OH, USA
## Franklin County, OH, USA
## Ohio, USA
## United States
rgc_more
## [1] "411 Woody Hayes Dr, Columbus, OH 43210, USA"
#gives all details of the address
rgc_all <- revgeocode(c(-83.01973, 40.00166), output="all")
rgc_all
## $plus_code
## $plus_code$compound_code
## [1] "2X2J+M4 Columbus, OH, USA"
##
## $plus_code$global_code
## [1] "86GR2X2J+M4"
##
##
## $results
## $results[[1]]
## $results[[1]]$address_components
## $results[[1]]$address_components[[1]]
## $results[[1]]$address_components[[1]]$long_name
## [1] "411"
##
## $results[[1]]$address_components[[1]]$short_name
## [1] "411"
##
## $results[[1]]$address_components[[1]]$types
## $results[[1]]$address_components[[1]]$types[[1]]
## [1] "street_number"
##
##
##
## $results[[1]]$address_components[[2]]
## $results[[1]]$address_components[[2]]$long_name
## [1] "Woody Hayes Drive"
##
## $results[[1]]$address_components[[2]]$short_name
## [1] "Woody Hayes Dr"
##
## $results[[1]]$address_components[[2]]$types
## $results[[1]]$address_components[[2]]$types[[1]]
## [1] "route"
##
##
##
## $results[[1]]$address_components[[3]]
## $results[[1]]$address_components[[3]]$long_name
## [1] "The Ohio State University"
##
## $results[[1]]$address_components[[3]]$short_name
## [1] "The Ohio State University"
##
## $results[[1]]$address_components[[3]]$types
## $results[[1]]$address_components[[3]]$types[[1]]
## [1] "neighborhood"
##
## $results[[1]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
## $results[[1]]$address_components[[4]]
## $results[[1]]$address_components[[4]]$long_name
## [1] "Columbus"
##
## $results[[1]]$address_components[[4]]$short_name
## [1] "Columbus"
##
## $results[[1]]$address_components[[4]]$types
## $results[[1]]$address_components[[4]]$types[[1]]
## [1] "locality"
##
## $results[[1]]$address_components[[4]]$types[[2]]
## [1] "political"
##
##
##
## $results[[1]]$address_components[[5]]
## $results[[1]]$address_components[[5]]$long_name
## [1] "Franklin County"
##
## $results[[1]]$address_components[[5]]$short_name
## [1] "Franklin County"
##
## $results[[1]]$address_components[[5]]$types
## $results[[1]]$address_components[[5]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[1]]$address_components[[5]]$types[[2]]
## [1] "political"
##
##
##
## $results[[1]]$address_components[[6]]
## $results[[1]]$address_components[[6]]$long_name
## [1] "Ohio"
##
## $results[[1]]$address_components[[6]]$short_name
## [1] "OH"
##
## $results[[1]]$address_components[[6]]$types
## $results[[1]]$address_components[[6]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[1]]$address_components[[6]]$types[[2]]
## [1] "political"
##
##
##
## $results[[1]]$address_components[[7]]
## $results[[1]]$address_components[[7]]$long_name
## [1] "United States"
##
## $results[[1]]$address_components[[7]]$short_name
## [1] "US"
##
## $results[[1]]$address_components[[7]]$types
## $results[[1]]$address_components[[7]]$types[[1]]
## [1] "country"
##
## $results[[1]]$address_components[[7]]$types[[2]]
## [1] "political"
##
##
##
## $results[[1]]$address_components[[8]]
## $results[[1]]$address_components[[8]]$long_name
## [1] "43210"
##
## $results[[1]]$address_components[[8]]$short_name
## [1] "43210"
##
## $results[[1]]$address_components[[8]]$types
## $results[[1]]$address_components[[8]]$types[[1]]
## [1] "postal_code"
##
##
##
##
## $results[[1]]$formatted_address
## [1] "411 Woody Hayes Dr, Columbus, OH 43210, USA"
##
## $results[[1]]$geometry
## $results[[1]]$geometry$location
## $results[[1]]$geometry$location$lat
## [1] 40.00166
##
## $results[[1]]$geometry$location$lng
## [1] -83.01973
##
##
## $results[[1]]$geometry$location_type
## [1] "ROOFTOP"
##
## $results[[1]]$geometry$viewport
## $results[[1]]$geometry$viewport$northeast
## $results[[1]]$geometry$viewport$northeast$lat
## [1] 40.00301
##
## $results[[1]]$geometry$viewport$northeast$lng
## [1] -83.01838
##
##
## $results[[1]]$geometry$viewport$southwest
## $results[[1]]$geometry$viewport$southwest$lat
## [1] 40.00031
##
## $results[[1]]$geometry$viewport$southwest$lng
## [1] -83.02108
##
##
##
##
## $results[[1]]$place_id
## [1] "ChIJVX_yAZSOOIgRpZhJFs2DSUs"
##
## $results[[1]]$plus_code
## $results[[1]]$plus_code$compound_code
## [1] "2X2J+M4 Columbus, Ohio, United States"
##
## $results[[1]]$plus_code$global_code
## [1] "86GR2X2J+M4"
##
##
## $results[[1]]$types
## $results[[1]]$types[[1]]
## [1] "establishment"
##
## $results[[1]]$types[[2]]
## [1] "point_of_interest"
##
## $results[[1]]$types[[3]]
## [1] "stadium"
##
##
##
## $results[[2]]
## $results[[2]]$address_components
## $results[[2]]$address_components[[1]]
## $results[[2]]$address_components[[1]]$long_name
## [1] "411"
##
## $results[[2]]$address_components[[1]]$short_name
## [1] "411"
##
## $results[[2]]$address_components[[1]]$types
## $results[[2]]$address_components[[1]]$types[[1]]
## [1] "street_number"
##
##
##
## $results[[2]]$address_components[[2]]
## $results[[2]]$address_components[[2]]$long_name
## [1] "Woody Hayes Drive"
##
## $results[[2]]$address_components[[2]]$short_name
## [1] "Woody Hayes Dr"
##
## $results[[2]]$address_components[[2]]$types
## $results[[2]]$address_components[[2]]$types[[1]]
## [1] "route"
##
##
##
## $results[[2]]$address_components[[3]]
## $results[[2]]$address_components[[3]]$long_name
## [1] "The Ohio State University"
##
## $results[[2]]$address_components[[3]]$short_name
## [1] "The Ohio State University"
##
## $results[[2]]$address_components[[3]]$types
## $results[[2]]$address_components[[3]]$types[[1]]
## [1] "neighborhood"
##
## $results[[2]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
## $results[[2]]$address_components[[4]]
## $results[[2]]$address_components[[4]]$long_name
## [1] "Columbus"
##
## $results[[2]]$address_components[[4]]$short_name
## [1] "Columbus"
##
## $results[[2]]$address_components[[4]]$types
## $results[[2]]$address_components[[4]]$types[[1]]
## [1] "locality"
##
## $results[[2]]$address_components[[4]]$types[[2]]
## [1] "political"
##
##
##
## $results[[2]]$address_components[[5]]
## $results[[2]]$address_components[[5]]$long_name
## [1] "Franklin County"
##
## $results[[2]]$address_components[[5]]$short_name
## [1] "Franklin County"
##
## $results[[2]]$address_components[[5]]$types
## $results[[2]]$address_components[[5]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[2]]$address_components[[5]]$types[[2]]
## [1] "political"
##
##
##
## $results[[2]]$address_components[[6]]
## $results[[2]]$address_components[[6]]$long_name
## [1] "Ohio"
##
## $results[[2]]$address_components[[6]]$short_name
## [1] "OH"
##
## $results[[2]]$address_components[[6]]$types
## $results[[2]]$address_components[[6]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[2]]$address_components[[6]]$types[[2]]
## [1] "political"
##
##
##
## $results[[2]]$address_components[[7]]
## $results[[2]]$address_components[[7]]$long_name
## [1] "United States"
##
## $results[[2]]$address_components[[7]]$short_name
## [1] "US"
##
## $results[[2]]$address_components[[7]]$types
## $results[[2]]$address_components[[7]]$types[[1]]
## [1] "country"
##
## $results[[2]]$address_components[[7]]$types[[2]]
## [1] "political"
##
##
##
## $results[[2]]$address_components[[8]]
## $results[[2]]$address_components[[8]]$long_name
## [1] "43210"
##
## $results[[2]]$address_components[[8]]$short_name
## [1] "43210"
##
## $results[[2]]$address_components[[8]]$types
## $results[[2]]$address_components[[8]]$types[[1]]
## [1] "postal_code"
##
##
##
##
## $results[[2]]$formatted_address
## [1] "411 Woody Hayes Dr, Columbus, OH 43210, USA"
##
## $results[[2]]$geometry
## $results[[2]]$geometry$location
## $results[[2]]$geometry$location$lat
## [1] 40.00164
##
## $results[[2]]$geometry$location$lng
## [1] -83.01973
##
##
## $results[[2]]$geometry$location_type
## [1] "ROOFTOP"
##
## $results[[2]]$geometry$viewport
## $results[[2]]$geometry$viewport$northeast
## $results[[2]]$geometry$viewport$northeast$lat
## [1] 40.00299
##
## $results[[2]]$geometry$viewport$northeast$lng
## [1] -83.01838
##
##
## $results[[2]]$geometry$viewport$southwest
## $results[[2]]$geometry$viewport$southwest$lat
## [1] 40.0003
##
## $results[[2]]$geometry$viewport$southwest$lng
## [1] -83.02108
##
##
##
##
## $results[[2]]$place_id
## [1] "ChIJDQWSspaOOIgRThu5Fbm4060"
##
## $results[[2]]$plus_code
## $results[[2]]$plus_code$compound_code
## [1] "2X2J+M4 Columbus, Ohio, United States"
##
## $results[[2]]$plus_code$global_code
## [1] "86GR2X2J+M4"
##
##
## $results[[2]]$types
## $results[[2]]$types[[1]]
## [1] "street_address"
##
##
##
## $results[[3]]
## $results[[3]]$address_components
## $results[[3]]$address_components[[1]]
## $results[[3]]$address_components[[1]]$long_name
## [1] "Unnamed Road"
##
## $results[[3]]$address_components[[1]]$short_name
## [1] "Unnamed Road"
##
## $results[[3]]$address_components[[1]]$types
## $results[[3]]$address_components[[1]]$types[[1]]
## [1] "route"
##
##
##
## $results[[3]]$address_components[[2]]
## $results[[3]]$address_components[[2]]$long_name
## [1] "The Ohio State University"
##
## $results[[3]]$address_components[[2]]$short_name
## [1] "The Ohio State University"
##
## $results[[3]]$address_components[[2]]$types
## $results[[3]]$address_components[[2]]$types[[1]]
## [1] "neighborhood"
##
## $results[[3]]$address_components[[2]]$types[[2]]
## [1] "political"
##
##
##
## $results[[3]]$address_components[[3]]
## $results[[3]]$address_components[[3]]$long_name
## [1] "Columbus"
##
## $results[[3]]$address_components[[3]]$short_name
## [1] "Columbus"
##
## $results[[3]]$address_components[[3]]$types
## $results[[3]]$address_components[[3]]$types[[1]]
## [1] "locality"
##
## $results[[3]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
## $results[[3]]$address_components[[4]]
## $results[[3]]$address_components[[4]]$long_name
## [1] "Franklin County"
##
## $results[[3]]$address_components[[4]]$short_name
## [1] "Franklin County"
##
## $results[[3]]$address_components[[4]]$types
## $results[[3]]$address_components[[4]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[3]]$address_components[[4]]$types[[2]]
## [1] "political"
##
##
##
## $results[[3]]$address_components[[5]]
## $results[[3]]$address_components[[5]]$long_name
## [1] "Ohio"
##
## $results[[3]]$address_components[[5]]$short_name
## [1] "OH"
##
## $results[[3]]$address_components[[5]]$types
## $results[[3]]$address_components[[5]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[3]]$address_components[[5]]$types[[2]]
## [1] "political"
##
##
##
## $results[[3]]$address_components[[6]]
## $results[[3]]$address_components[[6]]$long_name
## [1] "United States"
##
## $results[[3]]$address_components[[6]]$short_name
## [1] "US"
##
## $results[[3]]$address_components[[6]]$types
## $results[[3]]$address_components[[6]]$types[[1]]
## [1] "country"
##
## $results[[3]]$address_components[[6]]$types[[2]]
## [1] "political"
##
##
##
## $results[[3]]$address_components[[7]]
## $results[[3]]$address_components[[7]]$long_name
## [1] "43210"
##
## $results[[3]]$address_components[[7]]$short_name
## [1] "43210"
##
## $results[[3]]$address_components[[7]]$types
## $results[[3]]$address_components[[7]]$types[[1]]
## [1] "postal_code"
##
##
##
##
## $results[[3]]$formatted_address
## [1] "Unnamed Road, Columbus, OH 43210, USA"
##
## $results[[3]]$geometry
## $results[[3]]$geometry$bounds
## $results[[3]]$geometry$bounds$northeast
## $results[[3]]$geometry$bounds$northeast$lat
## [1] 40.00196
##
## $results[[3]]$geometry$bounds$northeast$lng
## [1] -83.02098
##
##
## $results[[3]]$geometry$bounds$southwest
## $results[[3]]$geometry$bounds$southwest$lat
## [1] 40.00176
##
## $results[[3]]$geometry$bounds$southwest$lng
## [1] -83.02102
##
##
##
## $results[[3]]$geometry$location
## $results[[3]]$geometry$location$lat
## [1] 40.00186
##
## $results[[3]]$geometry$location$lng
## [1] -83.021
##
##
## $results[[3]]$geometry$location_type
## [1] "GEOMETRIC_CENTER"
##
## $results[[3]]$geometry$viewport
## $results[[3]]$geometry$viewport$northeast
## $results[[3]]$geometry$viewport$northeast$lat
## [1] 40.00321
##
## $results[[3]]$geometry$viewport$northeast$lng
## [1] -83.01965
##
##
## $results[[3]]$geometry$viewport$southwest
## $results[[3]]$geometry$viewport$southwest$lat
## [1] 40.00051
##
## $results[[3]]$geometry$viewport$southwest$lng
## [1] -83.02235
##
##
##
##
## $results[[3]]$place_id
## [1] "ChIJgyivWJGOOIgRfDv3ZdNHMkQ"
##
## $results[[3]]$types
## $results[[3]]$types[[1]]
## [1] "route"
##
##
##
## $results[[4]]
## $results[[4]]$address_components
## $results[[4]]$address_components[[1]]
## $results[[4]]$address_components[[1]]$long_name
## [1] "43210"
##
## $results[[4]]$address_components[[1]]$short_name
## [1] "43210"
##
## $results[[4]]$address_components[[1]]$types
## $results[[4]]$address_components[[1]]$types[[1]]
## [1] "postal_code"
##
##
##
## $results[[4]]$address_components[[2]]
## $results[[4]]$address_components[[2]]$long_name
## [1] "Columbus"
##
## $results[[4]]$address_components[[2]]$short_name
## [1] "Columbus"
##
## $results[[4]]$address_components[[2]]$types
## $results[[4]]$address_components[[2]]$types[[1]]
## [1] "locality"
##
## $results[[4]]$address_components[[2]]$types[[2]]
## [1] "political"
##
##
##
## $results[[4]]$address_components[[3]]
## $results[[4]]$address_components[[3]]$long_name
## [1] "Franklin County"
##
## $results[[4]]$address_components[[3]]$short_name
## [1] "Franklin County"
##
## $results[[4]]$address_components[[3]]$types
## $results[[4]]$address_components[[3]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[4]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
## $results[[4]]$address_components[[4]]
## $results[[4]]$address_components[[4]]$long_name
## [1] "Ohio"
##
## $results[[4]]$address_components[[4]]$short_name
## [1] "OH"
##
## $results[[4]]$address_components[[4]]$types
## $results[[4]]$address_components[[4]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[4]]$address_components[[4]]$types[[2]]
## [1] "political"
##
##
##
## $results[[4]]$address_components[[5]]
## $results[[4]]$address_components[[5]]$long_name
## [1] "United States"
##
## $results[[4]]$address_components[[5]]$short_name
## [1] "US"
##
## $results[[4]]$address_components[[5]]$types
## $results[[4]]$address_components[[5]]$types[[1]]
## [1] "country"
##
## $results[[4]]$address_components[[5]]$types[[2]]
## [1] "political"
##
##
##
##
## $results[[4]]$formatted_address
## [1] "Columbus, OH 43210, USA"
##
## $results[[4]]$geometry
## $results[[4]]$geometry$bounds
## $results[[4]]$geometry$bounds$northeast
## $results[[4]]$geometry$bounds$northeast$lat
## [1] 40.01832
##
## $results[[4]]$geometry$bounds$northeast$lng
## [1] -83.00711
##
##
## $results[[4]]$geometry$bounds$southwest
## $results[[4]]$geometry$bounds$southwest$lat
## [1] 39.99069
##
## $results[[4]]$geometry$bounds$southwest$lng
## [1] -83.04083
##
##
##
## $results[[4]]$geometry$location
## $results[[4]]$geometry$location$lat
## [1] 39.99906
##
## $results[[4]]$geometry$location$lng
## [1] -83.01734
##
##
## $results[[4]]$geometry$location_type
## [1] "APPROXIMATE"
##
## $results[[4]]$geometry$viewport
## $results[[4]]$geometry$viewport$northeast
## $results[[4]]$geometry$viewport$northeast$lat
## [1] 40.01832
##
## $results[[4]]$geometry$viewport$northeast$lng
## [1] -83.00711
##
##
## $results[[4]]$geometry$viewport$southwest
## $results[[4]]$geometry$viewport$southwest$lat
## [1] 39.99069
##
## $results[[4]]$geometry$viewport$southwest$lng
## [1] -83.04083
##
##
##
##
## $results[[4]]$place_id
## [1] "ChIJqS2kpY-OOIgRFnTLCrszXxo"
##
## $results[[4]]$types
## $results[[4]]$types[[1]]
## [1] "postal_code"
##
##
##
## $results[[5]]
## $results[[5]]$address_components
## $results[[5]]$address_components[[1]]
## $results[[5]]$address_components[[1]]$long_name
## [1] "The Ohio State University"
##
## $results[[5]]$address_components[[1]]$short_name
## [1] "The Ohio State University"
##
## $results[[5]]$address_components[[1]]$types
## $results[[5]]$address_components[[1]]$types[[1]]
## [1] "neighborhood"
##
## $results[[5]]$address_components[[1]]$types[[2]]
## [1] "political"
##
##
##
## $results[[5]]$address_components[[2]]
## $results[[5]]$address_components[[2]]$long_name
## [1] "Columbus"
##
## $results[[5]]$address_components[[2]]$short_name
## [1] "Columbus"
##
## $results[[5]]$address_components[[2]]$types
## $results[[5]]$address_components[[2]]$types[[1]]
## [1] "locality"
##
## $results[[5]]$address_components[[2]]$types[[2]]
## [1] "political"
##
##
##
## $results[[5]]$address_components[[3]]
## $results[[5]]$address_components[[3]]$long_name
## [1] "Clinton Township"
##
## $results[[5]]$address_components[[3]]$short_name
## [1] "Clinton Township"
##
## $results[[5]]$address_components[[3]]$types
## $results[[5]]$address_components[[3]]$types[[1]]
## [1] "administrative_area_level_3"
##
## $results[[5]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
## $results[[5]]$address_components[[4]]
## $results[[5]]$address_components[[4]]$long_name
## [1] "Franklin County"
##
## $results[[5]]$address_components[[4]]$short_name
## [1] "Franklin County"
##
## $results[[5]]$address_components[[4]]$types
## $results[[5]]$address_components[[4]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[5]]$address_components[[4]]$types[[2]]
## [1] "political"
##
##
##
## $results[[5]]$address_components[[5]]
## $results[[5]]$address_components[[5]]$long_name
## [1] "Ohio"
##
## $results[[5]]$address_components[[5]]$short_name
## [1] "OH"
##
## $results[[5]]$address_components[[5]]$types
## $results[[5]]$address_components[[5]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[5]]$address_components[[5]]$types[[2]]
## [1] "political"
##
##
##
## $results[[5]]$address_components[[6]]
## $results[[5]]$address_components[[6]]$long_name
## [1] "United States"
##
## $results[[5]]$address_components[[6]]$short_name
## [1] "US"
##
## $results[[5]]$address_components[[6]]$types
## $results[[5]]$address_components[[6]]$types[[1]]
## [1] "country"
##
## $results[[5]]$address_components[[6]]$types[[2]]
## [1] "political"
##
##
##
##
## $results[[5]]$formatted_address
## [1] "The Ohio State University, Columbus, OH, USA"
##
## $results[[5]]$geometry
## $results[[5]]$geometry$bounds
## $results[[5]]$geometry$bounds$northeast
## $results[[5]]$geometry$bounds$northeast$lat
## [1] 40.01846
##
## $results[[5]]$geometry$bounds$northeast$lng
## [1] -83.00744
##
##
## $results[[5]]$geometry$bounds$southwest
## $results[[5]]$geometry$bounds$southwest$lat
## [1] 39.99068
##
## $results[[5]]$geometry$bounds$southwest$lng
## [1] -83.03421
##
##
##
## $results[[5]]$geometry$location
## $results[[5]]$geometry$location$lat
## [1] 39.99939
##
## $results[[5]]$geometry$location$lng
## [1] -83.02271
##
##
## $results[[5]]$geometry$location_type
## [1] "APPROXIMATE"
##
## $results[[5]]$geometry$viewport
## $results[[5]]$geometry$viewport$northeast
## $results[[5]]$geometry$viewport$northeast$lat
## [1] 40.01846
##
## $results[[5]]$geometry$viewport$northeast$lng
## [1] -83.00744
##
##
## $results[[5]]$geometry$viewport$southwest
## $results[[5]]$geometry$viewport$southwest$lat
## [1] 39.99068
##
## $results[[5]]$geometry$viewport$southwest$lng
## [1] -83.03421
##
##
##
##
## $results[[5]]$place_id
## [1] "ChIJZ7Gv2ZCOOIgR4H1y8s9FBeU"
##
## $results[[5]]$types
## $results[[5]]$types[[1]]
## [1] "neighborhood"
##
## $results[[5]]$types[[2]]
## [1] "political"
##
##
##
## $results[[6]]
## $results[[6]]$address_components
## $results[[6]]$address_components[[1]]
## $results[[6]]$address_components[[1]]$long_name
## [1] "Columbus"
##
## $results[[6]]$address_components[[1]]$short_name
## [1] "Columbus"
##
## $results[[6]]$address_components[[1]]$types
## $results[[6]]$address_components[[1]]$types[[1]]
## [1] "locality"
##
## $results[[6]]$address_components[[1]]$types[[2]]
## [1] "political"
##
##
##
## $results[[6]]$address_components[[2]]
## $results[[6]]$address_components[[2]]$long_name
## [1] "Franklin County"
##
## $results[[6]]$address_components[[2]]$short_name
## [1] "Franklin County"
##
## $results[[6]]$address_components[[2]]$types
## $results[[6]]$address_components[[2]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[6]]$address_components[[2]]$types[[2]]
## [1] "political"
##
##
##
## $results[[6]]$address_components[[3]]
## $results[[6]]$address_components[[3]]$long_name
## [1] "Ohio"
##
## $results[[6]]$address_components[[3]]$short_name
## [1] "OH"
##
## $results[[6]]$address_components[[3]]$types
## $results[[6]]$address_components[[3]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[6]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
## $results[[6]]$address_components[[4]]
## $results[[6]]$address_components[[4]]$long_name
## [1] "United States"
##
## $results[[6]]$address_components[[4]]$short_name
## [1] "US"
##
## $results[[6]]$address_components[[4]]$types
## $results[[6]]$address_components[[4]]$types[[1]]
## [1] "country"
##
## $results[[6]]$address_components[[4]]$types[[2]]
## [1] "political"
##
##
##
##
## $results[[6]]$formatted_address
## [1] "Columbus, OH, USA"
##
## $results[[6]]$geometry
## $results[[6]]$geometry$bounds
## $results[[6]]$geometry$bounds$northeast
## $results[[6]]$geometry$bounds$northeast$lat
## [1] 40.15727
##
## $results[[6]]$geometry$bounds$northeast$lng
## [1] -82.77138
##
##
## $results[[6]]$geometry$bounds$southwest
## $results[[6]]$geometry$bounds$southwest$lat
## [1] 39.80863
##
## $results[[6]]$geometry$bounds$southwest$lng
## [1] -83.21028
##
##
##
## $results[[6]]$geometry$location
## $results[[6]]$geometry$location$lat
## [1] 39.96118
##
## $results[[6]]$geometry$location$lng
## [1] -82.99879
##
##
## $results[[6]]$geometry$location_type
## [1] "APPROXIMATE"
##
## $results[[6]]$geometry$viewport
## $results[[6]]$geometry$viewport$northeast
## $results[[6]]$geometry$viewport$northeast$lat
## [1] 40.15727
##
## $results[[6]]$geometry$viewport$northeast$lng
## [1] -82.77138
##
##
## $results[[6]]$geometry$viewport$southwest
## $results[[6]]$geometry$viewport$southwest$lat
## [1] 39.80863
##
## $results[[6]]$geometry$viewport$southwest$lng
## [1] -83.21028
##
##
##
##
## $results[[6]]$place_id
## [1] "ChIJcd6QucGJOIgRM7Wxz_hmMuQ"
##
## $results[[6]]$types
## $results[[6]]$types[[1]]
## [1] "locality"
##
## $results[[6]]$types[[2]]
## [1] "political"
##
##
##
## $results[[7]]
## $results[[7]]$address_components
## $results[[7]]$address_components[[1]]
## $results[[7]]$address_components[[1]]$long_name
## [1] "Franklin County"
##
## $results[[7]]$address_components[[1]]$short_name
## [1] "Franklin County"
##
## $results[[7]]$address_components[[1]]$types
## $results[[7]]$address_components[[1]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[7]]$address_components[[1]]$types[[2]]
## [1] "political"
##
##
##
## $results[[7]]$address_components[[2]]
## $results[[7]]$address_components[[2]]$long_name
## [1] "Ohio"
##
## $results[[7]]$address_components[[2]]$short_name
## [1] "OH"
##
## $results[[7]]$address_components[[2]]$types
## $results[[7]]$address_components[[2]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[7]]$address_components[[2]]$types[[2]]
## [1] "political"
##
##
##
## $results[[7]]$address_components[[3]]
## $results[[7]]$address_components[[3]]$long_name
## [1] "United States"
##
## $results[[7]]$address_components[[3]]$short_name
## [1] "US"
##
## $results[[7]]$address_components[[3]]$types
## $results[[7]]$address_components[[3]]$types[[1]]
## [1] "country"
##
## $results[[7]]$address_components[[3]]$types[[2]]
## [1] "political"
##
##
##
##
## $results[[7]]$formatted_address
## [1] "Franklin County, OH, USA"
##
## $results[[7]]$geometry
## $results[[7]]$geometry$bounds
## $results[[7]]$geometry$bounds$northeast
## $results[[7]]$geometry$bounds$northeast$lat
## [1] 40.14309
##
## $results[[7]]$geometry$bounds$northeast$lng
## [1] -82.76183
##
##
## $results[[7]]$geometry$bounds$southwest
## $results[[7]]$geometry$bounds$southwest$lat
## [1] 39.795
##
## $results[[7]]$geometry$bounds$southwest$lng
## [1] -83.26088
##
##
##
## $results[[7]]$geometry$location
## $results[[7]]$geometry$location$lat
## [1] 40.01547
##
## $results[[7]]$geometry$location$lng
## [1] -82.99316
##
##
## $results[[7]]$geometry$location_type
## [1] "APPROXIMATE"
##
## $results[[7]]$geometry$viewport
## $results[[7]]$geometry$viewport$northeast
## $results[[7]]$geometry$viewport$northeast$lat
## [1] 40.14309
##
## $results[[7]]$geometry$viewport$northeast$lng
## [1] -82.76183
##
##
## $results[[7]]$geometry$viewport$southwest
## $results[[7]]$geometry$viewport$southwest$lat
## [1] 39.795
##
## $results[[7]]$geometry$viewport$southwest$lng
## [1] -83.26088
##
##
##
##
## $results[[7]]$place_id
## [1] "ChIJcd6QucGJOIgR3zgRtZz7NcQ"
##
## $results[[7]]$types
## $results[[7]]$types[[1]]
## [1] "administrative_area_level_2"
##
## $results[[7]]$types[[2]]
## [1] "political"
##
##
##
## $results[[8]]
## $results[[8]]$address_components
## $results[[8]]$address_components[[1]]
## $results[[8]]$address_components[[1]]$long_name
## [1] "Ohio"
##
## $results[[8]]$address_components[[1]]$short_name
## [1] "OH"
##
## $results[[8]]$address_components[[1]]$types
## $results[[8]]$address_components[[1]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[8]]$address_components[[1]]$types[[2]]
## [1] "political"
##
##
##
## $results[[8]]$address_components[[2]]
## $results[[8]]$address_components[[2]]$long_name
## [1] "United States"
##
## $results[[8]]$address_components[[2]]$short_name
## [1] "US"
##
## $results[[8]]$address_components[[2]]$types
## $results[[8]]$address_components[[2]]$types[[1]]
## [1] "country"
##
## $results[[8]]$address_components[[2]]$types[[2]]
## [1] "political"
##
##
##
##
## $results[[8]]$formatted_address
## [1] "Ohio, USA"
##
## $results[[8]]$geometry
## $results[[8]]$geometry$bounds
## $results[[8]]$geometry$bounds$northeast
## $results[[8]]$geometry$bounds$northeast$lat
## [1] 42.32713
##
## $results[[8]]$geometry$bounds$northeast$lng
## [1] -80.5182
##
##
## $results[[8]]$geometry$bounds$southwest
## $results[[8]]$geometry$bounds$southwest$lat
## [1] 38.40342
##
## $results[[8]]$geometry$bounds$southwest$lng
## [1] -84.8203
##
##
##
## $results[[8]]$geometry$location
## $results[[8]]$geometry$location$lat
## [1] 40.41729
##
## $results[[8]]$geometry$location$lng
## [1] -82.90712
##
##
## $results[[8]]$geometry$location_type
## [1] "APPROXIMATE"
##
## $results[[8]]$geometry$viewport
## $results[[8]]$geometry$viewport$northeast
## $results[[8]]$geometry$viewport$northeast$lat
## [1] 42.32713
##
## $results[[8]]$geometry$viewport$northeast$lng
## [1] -80.5182
##
##
## $results[[8]]$geometry$viewport$southwest
## $results[[8]]$geometry$viewport$southwest$lat
## [1] 38.40342
##
## $results[[8]]$geometry$viewport$southwest$lng
## [1] -84.8203
##
##
##
##
## $results[[8]]$place_id
## [1] "ChIJwY5NtXrpNogRFtmfnDlkzeU"
##
## $results[[8]]$types
## $results[[8]]$types[[1]]
## [1] "administrative_area_level_1"
##
## $results[[8]]$types[[2]]
## [1] "political"
##
##
##
## $results[[9]]
## $results[[9]]$address_components
## $results[[9]]$address_components[[1]]
## $results[[9]]$address_components[[1]]$long_name
## [1] "United States"
##
## $results[[9]]$address_components[[1]]$short_name
## [1] "US"
##
## $results[[9]]$address_components[[1]]$types
## $results[[9]]$address_components[[1]]$types[[1]]
## [1] "country"
##
## $results[[9]]$address_components[[1]]$types[[2]]
## [1] "political"
##
##
##
##
## $results[[9]]$formatted_address
## [1] "United States"
##
## $results[[9]]$geometry
## $results[[9]]$geometry$bounds
## $results[[9]]$geometry$bounds$northeast
## $results[[9]]$geometry$bounds$northeast$lat
## [1] 71.5388
##
## $results[[9]]$geometry$bounds$northeast$lng
## [1] -66.88542
##
##
## $results[[9]]$geometry$bounds$southwest
## $results[[9]]$geometry$bounds$southwest$lat
## [1] 18.7763
##
## $results[[9]]$geometry$bounds$southwest$lng
## [1] 170.5957
##
##
##
## $results[[9]]$geometry$location
## $results[[9]]$geometry$location$lat
## [1] 37.09024
##
## $results[[9]]$geometry$location$lng
## [1] -95.71289
##
##
## $results[[9]]$geometry$location_type
## [1] "APPROXIMATE"
##
## $results[[9]]$geometry$viewport
## $results[[9]]$geometry$viewport$northeast
## $results[[9]]$geometry$viewport$northeast$lat
## [1] 71.5388
##
## $results[[9]]$geometry$viewport$northeast$lng
## [1] -66.88542
##
##
## $results[[9]]$geometry$viewport$southwest
## $results[[9]]$geometry$viewport$southwest$lat
## [1] 18.7763
##
## $results[[9]]$geometry$viewport$southwest$lng
## [1] 170.5957
##
##
##
##
## $results[[9]]$place_id
## [1] "ChIJCzYy5IS16lQRQrfeQ5K5Oxw"
##
## $results[[9]]$types
## $results[[9]]$types[[1]]
## [1] "country"
##
## $results[[9]]$types[[2]]
## [1] "political"
##
##
##
##
## $status
## [1] "OK"
sb <- read_csv("directory starbucks.csv")
## Parsed with column specification:
## cols(
## Brand = col_character(),
## `Store Number` = col_character(),
## `Store Name` = col_character(),
## `Ownership Type` = col_character(),
## `Street Address` = col_character(),
## City = col_character(),
## `State/Province` = col_character(),
## Country = col_character(),
## Postcode = col_character(),
## `Phone Number` = col_character(),
## Timezone = col_character(),
## Longitude = col_double(),
## Latitude = col_double()
## )
sboh <- sb %>% filter(Country=="US" & `State/Province`=="OH")
#Creating addresses for geocoding
sboh10 <- sboh %>%
filter(str_to_lower(City)=="columbus") %>%
sample_n(10) %>%
mutate(address=sprintf("%s, %s, %s %s", `Street Address`, City,
`State/Province`, str_sub(Postcode,1,5)))
sboh10$address
## [1] "1500 Polaris Parkway, Space 2066, Easton Town Center, Columbus, OH 43240"
## [2] "965 Bethel Road, Columbus, OH 43214"
## [3] "6470 Sawmill Road, Easton Fashion District, Columbus, OH 43235"
## [4] "1581 Hilliard-Rome Road, Columbus, OH 43228"
## [5] "160 EASTON TOWN CENTER, COLUMBUS, OH 43219"
## [6] "1745 Morse Road, Columbus, OH 43229"
## [7] "7000 E Broad St, Columbus, OH 43213"
## [8] "1187 Polaris Parkway, Columbus, OH 43240"
## [9] "4600 International Gateway, Columbus, OH 43219"
## [10] "1177 Polaris Parkway, Columbus, OH 43240"
#Batch Geocoding with Google Maps API to add the lat and lon
sboh10ll <- sboh10 %>% mutate_geocode(address)
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=1500+Polaris+Parkway,+Space+2066,+Easton+Town+Center,+Columbus,+OH+43240&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=965+Bethel+Road,+Columbus,+OH+43214&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=6470+Sawmill+Road,+Easton+Fashion+District,+Columbus,+OH+43235&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=1581+Hilliard-Rome+Road,+Columbus,+OH+43228&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=160+EASTON+TOWN+CENTER,+COLUMBUS,+OH+43219&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=1745+Morse+Road,+Columbus,+OH+43229&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=7000+E+Broad+St,+Columbus,+OH+43213&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=1187+Polaris+Parkway,+Columbus,+OH+43240&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=4600+International+Gateway,+Columbus,+OH+43219&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=1177+Polaris+Parkway,+Columbus,+OH+43240&key=xxx
sboh10ll
## # A tibble: 10 x 16
## Brand `Store Number` `Store Name` `Ownership Type` `Street Address`
## <chr> <chr> <chr> <chr> <chr>
## 1 Star… 2638-29316 Polaris Fas… Company Owned 1500 Polaris Pa…
## 2 Star… 10975-103351 Bethel Road Company Owned 965 Bethel Road
## 3 Star… 2519-233070 Sawmill Pla… Company Owned 6470 Sawmill Ro…
## 4 Star… 25091-239807 Shops at Hi… Company Owned 1581 Hilliard-R…
## 5 Teav… 28423-249807 Teavana - E… Company Owned 160 EASTON TOWN…
## 6 Star… 28261-243829 Kroger Colu… Licensed 1745 Morse Road
## 7 Star… 19394-93009 Kroger-Colu… Licensed 7000 E Broad St
## 8 Star… 2355-4430 Polaris Company Owned 1187 Polaris Pa…
## 9 Star… 75970-107910 CMH C-Conco… Licensed 4600 Internatio…
## 10 Star… 26359-243806 Kroger Colu… Licensed 1177 Polaris Pa…
## # … with 11 more variables: City <chr>, `State/Province` <chr>,
## # Country <chr>, Postcode <chr>, `Phone Number` <chr>, Timezone <chr>,
## # Longitude <dbl>, Latitude <dbl>, address <chr>, lon <dbl>, lat <dbl>
# to get file for all 378 locations with Lat Lon
sbohll2 <- read_csv("sbohll.csv")
## Parsed with column specification:
## cols(
## Brand = col_character(),
## `Store Number` = col_character(),
## `Store Name` = col_character(),
## `Ownership Type` = col_character(),
## `Street Address` = col_character(),
## City = col_character(),
## `State/Province` = col_character(),
## Country = col_character(),
## Postcode = col_double(),
## `Phone Number` = col_character(),
## Timezone = col_character(),
## Longitude = col_double(),
## Latitude = col_double(),
## address = col_character(),
## lon = col_double(),
## lat = col_double()
## )
#Visualizing points
mapoh <- county %>% filter(region=="ohio")
ggplot() +
geom_path(data=mapoh, aes(long, lat, group=group), color="gray70") +
geom_point(data=sbohll2, aes(lon, lat, color=Brand, shape=`Ownership Type`), size=1, alpha=.5) +
coord_map("albers", lat0=40, lat1=41) + theme_minimal()
Columbus, Cincinnati , cleveleand and Toledo has big clusters and in rural area is sparsely scattered.
#Column names
names(sbohll2)
## [1] "Brand" "Store Number" "Store Name" "Ownership Type"
## [5] "Street Address" "City" "State/Province" "Country"
## [9] "Postcode" "Phone Number" "Timezone" "Longitude"
## [13] "Latitude" "address" "lon" "lat"
#xlim and ylim to limit space, unit of analysis is city not county level so not much information conveyed.
#this problem can be solved by ggmap
ggplot() +
geom_path(data=mapoh, aes(long, lat, group=group), color="gray70") + geom_point(data=sbohll2, aes(lon, lat, color=Brand, shape= `Ownership Type`), size=2, alpha=.5) +
coord_map("albers", lat0=40, lat1=41, xlim=c(-82.7,-83.3),
ylim=c(39.7,40.3)) + theme_minimal()
#OVERLAYING the actual map
cbusll <- geocode("Columbus, OH")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Columbus,+OH&key=xxx
cbusll
## # A tibble: 1 x 2
## lon lat
## <dbl> <dbl>
## 1 -83.0 40.0
#get map of columbus ohio
cbusmapgr <- get_map(cbusll,
maptype="roadmap", source="google")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.961176,-82.998794&zoom=10&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx
cbusmapgr
## 1280x1280 roadmap map image from Google Maps.
## See ?ggmap to plot it.
ggmap(cbusmapgr) +
geom_point(data=sbohll2,
aes(lon, lat, color=Brand,
shape=`Ownership Type`),
size=2, alpha=.5)
## Warning: Removed 281 rows containing missing values (geom_point).
#lat lon of columbus numeric vector
cbusllg = as.numeric(cbusll)
get_googlemap(cbusllg, zoom=12, maptype="terrain") %>% ggmap()
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.961176,-82.998794&zoom=12&size=640x640&scale=2&maptype=terrain&key=xxx
get_googlemap(cbusllg, zoom=12, maptype="satellite") %>% ggmap()
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.961176,-82.998794&zoom=12&size=640x640&scale=2&maptype=satellite&key=xxx
get_googlemap(cbusllg, zoom=12, maptype="roadmap") %>% ggmap()
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.961176,-82.998794&zoom=12&size=640x640&scale=2&maptype=roadmap&key=xxx
get_googlemap(cbusllg, zoom=12, maptype="hybrid") %>% ggmap()
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.961176,-82.998794&zoom=12&size=640x640&scale=2&maptype=hybrid&key=xxx
cbusmapz12 <- get_map(cbusll, zoom=12)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=39.961176,-82.998794&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
cbusmapz12
## 1280x1280 terrain map image from Google Maps.
## See ?ggmap to plot it.
#bb is the bounding box
cbusbb <- attr(cbusmapz12, "bb")
cbusbb
## # A tibble: 1 x 4
## ll.lat ll.lon ur.lat ur.lon
## <dbl> <dbl> <dbl> <dbl>
## 1 39.9 -83.1 40.0 -82.9
cbusbbox <- bb2bbox(cbusbb)
cbusbbox
## left bottom right top
## -83.10849 39.87678 -82.88876 40.04520
#EXPLORE STAMEN MAPS
get_stamenmap(cbusbbox, zoom=12, maptype="terrain") %>% ggmap()
## Source : http://tile.stamen.com/terrain/12/1102/1549.png
## Source : http://tile.stamen.com/terrain/12/1103/1549.png
## Source : http://tile.stamen.com/terrain/12/1104/1549.png
## Source : http://tile.stamen.com/terrain/12/1102/1550.png
## Source : http://tile.stamen.com/terrain/12/1103/1550.png
## Source : http://tile.stamen.com/terrain/12/1104/1550.png
## Source : http://tile.stamen.com/terrain/12/1102/1551.png
## Source : http://tile.stamen.com/terrain/12/1103/1551.png
## Source : http://tile.stamen.com/terrain/12/1104/1551.png
## Source : http://tile.stamen.com/terrain/12/1102/1552.png
## Source : http://tile.stamen.com/terrain/12/1103/1552.png
## Source : http://tile.stamen.com/terrain/12/1104/1552.png
get_stamenmap(cbusbbox, zoom=12, maptype="terrain-lines") %>% ggmap()
## Source : http://tile.stamen.com/terrain-lines/12/1102/1549.png
## Source : http://tile.stamen.com/terrain-lines/12/1103/1549.png
## Source : http://tile.stamen.com/terrain-lines/12/1104/1549.png
## Source : http://tile.stamen.com/terrain-lines/12/1102/1550.png
## Source : http://tile.stamen.com/terrain-lines/12/1103/1550.png
## Source : http://tile.stamen.com/terrain-lines/12/1104/1550.png
## Source : http://tile.stamen.com/terrain-lines/12/1102/1551.png
## Source : http://tile.stamen.com/terrain-lines/12/1103/1551.png
## Source : http://tile.stamen.com/terrain-lines/12/1104/1551.png
## Source : http://tile.stamen.com/terrain-lines/12/1102/1552.png
## Source : http://tile.stamen.com/terrain-lines/12/1103/1552.png
## Source : http://tile.stamen.com/terrain-lines/12/1104/1552.png
get_stamenmap(cbusbbox, zoom=12, maptype="toner") %>% ggmap()
## Source : http://tile.stamen.com/toner/12/1102/1549.png
## Source : http://tile.stamen.com/toner/12/1103/1549.png
## Source : http://tile.stamen.com/toner/12/1104/1549.png
## Source : http://tile.stamen.com/toner/12/1102/1550.png
## Source : http://tile.stamen.com/toner/12/1103/1550.png
## Source : http://tile.stamen.com/toner/12/1104/1550.png
## Source : http://tile.stamen.com/toner/12/1102/1551.png
## Source : http://tile.stamen.com/toner/12/1103/1551.png
## Source : http://tile.stamen.com/toner/12/1104/1551.png
## Source : http://tile.stamen.com/toner/12/1102/1552.png
## Source : http://tile.stamen.com/toner/12/1103/1552.png
## Source : http://tile.stamen.com/toner/12/1104/1552.png
get_stamenmap(cbusbbox, zoom=12, maptype="toner-background") %>% ggmap()
## Source : http://tile.stamen.com/toner-background/12/1102/1549.png
## Source : http://tile.stamen.com/toner-background/12/1103/1549.png
## Source : http://tile.stamen.com/toner-background/12/1104/1549.png
## Source : http://tile.stamen.com/toner-background/12/1102/1550.png
## Source : http://tile.stamen.com/toner-background/12/1103/1550.png
## Source : http://tile.stamen.com/toner-background/12/1104/1550.png
## Source : http://tile.stamen.com/toner-background/12/1102/1551.png
## Source : http://tile.stamen.com/toner-background/12/1103/1551.png
## Source : http://tile.stamen.com/toner-background/12/1104/1551.png
## Source : http://tile.stamen.com/toner-background/12/1102/1552.png
## Source : http://tile.stamen.com/toner-background/12/1103/1552.png
## Source : http://tile.stamen.com/toner-background/12/1104/1552.png
get_stamenmap(cbusbbox, zoom=12, maptype="toner-lite") %>% ggmap()
## Source : http://tile.stamen.com/toner-lite/12/1102/1549.png
## Source : http://tile.stamen.com/toner-lite/12/1103/1549.png
## Source : http://tile.stamen.com/toner-lite/12/1104/1549.png
## Source : http://tile.stamen.com/toner-lite/12/1102/1550.png
## Source : http://tile.stamen.com/toner-lite/12/1103/1550.png
## Source : http://tile.stamen.com/toner-lite/12/1104/1550.png
## Source : http://tile.stamen.com/toner-lite/12/1102/1551.png
## Source : http://tile.stamen.com/toner-lite/12/1103/1551.png
## Source : http://tile.stamen.com/toner-lite/12/1104/1551.png
## Source : http://tile.stamen.com/toner-lite/12/1102/1552.png
## Source : http://tile.stamen.com/toner-lite/12/1103/1552.png
## Source : http://tile.stamen.com/toner-lite/12/1104/1552.png
get_stamenmap(cbusbbox, zoom=12, maptype="watercolor") %>% ggmap()
## Source : http://tile.stamen.com/watercolor/12/1102/1549.jpg
## Source : http://tile.stamen.com/watercolor/12/1103/1549.jpg
## Source : http://tile.stamen.com/watercolor/12/1104/1549.jpg
## Source : http://tile.stamen.com/watercolor/12/1102/1550.jpg
## Source : http://tile.stamen.com/watercolor/12/1103/1550.jpg
## Source : http://tile.stamen.com/watercolor/12/1104/1550.jpg
## Source : http://tile.stamen.com/watercolor/12/1102/1551.jpg
## Source : http://tile.stamen.com/watercolor/12/1103/1551.jpg
## Source : http://tile.stamen.com/watercolor/12/1104/1551.jpg
## Source : http://tile.stamen.com/watercolor/12/1102/1552.jpg
## Source : http://tile.stamen.com/watercolor/12/1103/1552.jpg
## Source : http://tile.stamen.com/watercolor/12/1104/1552.jpg
Creating small multiples with facet wrap
basemap <-
get_stamenmap(cbusbbox, zoom=12, maptype="toner") %>% ggmap()
basemap +
geom_point(data=sbohll2, aes(lon, lat, shape=`Ownership Type`),
color="#F8766D", size=2, alpha=.5) +
facet_wrap(~`Ownership Type`)
## Warning: Removed 356 rows containing missing values (geom_point).
Visualizing density with contour and heatmap
#starbucks density is high in downtown, upper arlington
basemap + geom_density2d(data=sbohll2, aes(lon, lat), color="red")
## Warning: Removed 356 rows containing non-finite values (stat_density2d).
basemap +
stat_density2d(data=sbohll2, aes(fill=..level..), geom="polygon", alpha=.3)+ scale_fill_gradient2(low="white", mid="yellow", high="red", midpoint=50)
## Warning: Removed 356 rows containing non-finite values (stat_density2d).
# From To
ohroute <- route("The Ohio Stadium", "Ohio State Golf Course", structure="route")
## Source : https://maps.googleapis.com/maps/api/directions/json?origin=The+Ohio+Stadium&destination=Ohio+State+Golf+Course&key=xxx&mode=driving&alternatives=false&units=metric
ohroute
## # A tibble: 5 x 9
## route m km miles seconds minutes hours lon lat
## <chr> <int> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl>
## 1 A 108 0.108 0.0671 23 0.383 0.00639 -83.0 40.0
## 2 A 1274 1.27 0.792 164 2.73 0.0456 -83.0 40.0
## 3 A 3604 3.60 2.24 320 5.33 0.0889 -83.0 40.0
## 4 A 224 0.224 0.139 31 0.517 0.00861 -83.1 40.0
## 5 A NA NA NA NA NA NA -83.1 40.0
ohtrek <- trek("The Ohio Stadium", "Ohio State Golf Course", structure="route")
## Source : https://maps.googleapis.com/maps/api/directions/json?origin=The+Ohio+Stadium&destination=Ohio+State+Golf+Course&key=xxx&mode=driving&alternatives=false&units=metric
ohtrek
## # A tibble: 65 x 3
## lat lon route
## <dbl> <dbl> <chr>
## 1 40.0 -83.0 A
## 2 40.0 -83.0 A
## 3 40.0 -83.0 A
## 4 40.0 -83.0 A
## 5 40.0 -83.0 A
## 6 40.0 -83.0 A
## 7 40.0 -83.0 A
## 8 40.0 -83.0 A
## 9 40.0 -83.0 A
## 10 40.0 -83.0 A
## # … with 55 more rows
#Visualizing a tracing path
get_map(c(lon=mean(ohroute$lon), lat=mean(ohroute$lat)), zoom=14, maptype="roadmap") %>% ggmap() +
geom_path(data=ohroute, aes(lon, lat), color="blue", size=1.5, alpha=.5, lineend="round")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.014888,-83.035322&zoom=14&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx
get_map(c(lon=mean(ohtrek$lon), lat=mean(ohtrek$lat)), zoom=14, maptype="roadmap") %>% ggmap() +
geom_path(data=ohtrek, aes(lon, lat), color="blue", size=1.5, alpha=.5, lineend="round")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.01463,-83.037189&zoom=14&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx